package com.ty.mianshiya.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ty.mianshiya.model.dto.questionBankQiestion.QuestionBankQuestionQueryRequest;
import com.ty.mianshiya.model.entity.QuestionBankQuestion;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ty.mianshiya.model.entity.User;
import com.ty.mianshiya.model.vo.QuestionBankQuestionVO;
import com.ty.mianshiya.model.vo.QuestionVO;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
* @author WangJiyou
* @description 针对表【question_bank_question(题库题目)】的数据库操作Service
* @createDate 2024-09-09 22:35:58
*/
public interface QuestionBankQuestionService extends IService<QuestionBankQuestion> {
    /**
     * 根据题库id查询题目
     */
    public List<QuestionVO> getQuestionsByBankId(Long questionBankId);

    void validQuestionBankQuestion(QuestionBankQuestion questionBankQuestion, boolean b);

    Wrapper<QuestionBankQuestion> getQueryWrapper(QuestionBankQuestionQueryRequest questionBankQuestionQueryRequest);

    Page<QuestionBankQuestionVO> getQuestionBankQuestionVOPage(Page<QuestionBankQuestion> questionBankQuestionPage, HttpServletRequest request);

    QuestionBankQuestionVO getQuestionBankQuestionVO(QuestionBankQuestion questionBankQuestion, HttpServletRequest request);
    /**
     * 批量向题库增加题目
     * @param questionIdList
     * @param questionBankId
     * @param loginUser
     */
    void batchAddQuestionToBank(List<Long> questionIdList, Long questionBankId, User loginUser);

    /**
     * 批量移除题库中题目
     * @param questionIdList
     * @param questionBankId
     */
    void batchRemoveQuestionFromBank(List<Long> questionIdList, Long questionBankId);

    /**
     * 批量向题库增加题目(避免长事务问题)
     */
    @Transactional(rollbackFor = Exception.class)
    void batchAddQuestionsToBankInner(List<QuestionBankQuestion> questionBankQuestions);

}
